package com.library.controller;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/*")
public class LoginFilter extends HttpFilter{
	
	protected void doFilter(HttpServletRequest req, HttpServletResponse resp,FilterChain chain) 
			throws ServletException, IOException {
		String uri = req.getRequestURI();
		if(uri.contains("login.jsp") || uri.contains("login.do")) {
			super.doFilter(req,resp,chain);
			return;
		}
		if(req.getSession().getAttribute("loginAdmin")!=null) {
			super.doFilter(req,resp,chain);
		}else {
			resp.sendRedirect("login.jsp");
		}
		
	}
}
